<%@ page contentType="text/html;charset=utf-8" language="java" %>
<html>
<head>
    <title>接受请求参数</title>
    <script type="text/javascript" src="js/jquery-3.3.1.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#myButton").on("click",function () {
                $.ajax({
                    url: "returnVoid.htm",
                    //url: "doStudentJson.do",
                    //url: "doStringData.do",
                    data: {
                        name: "张起灵",
                        age: 20
                    },
                    dataType: "json",
                    //dataType: "text",
                    success: function (resp) {
                        // resp=XMLHttpRequest.responseText;
                        alert("name===" + resp.name + ",age===" + resp.age);
                        //alert(resp);
                    }
                })
            })
        })
    </script>
</head>
<body>
<p>控制器返回String-逻辑视图名称</p>
<form action="returnVoid.htm" method="post">
    姓名：<input type="text" name="name"><br/>
    年龄：<input type="text" name="age"><br/>
    <input type="submit" value="提交参数">
</form>
<br/><br/>
<button id="myButton">提交ajax请求</button>
</body>
</html>